package day12;

import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.event.KeyEvent;
import java.util.Random;
import java.util.Scanner;

/**
 * @author wei zhijie
 * @version 1.0
 * @date 2021/1/9
 */
public class qq {
    public static void main(String[] args) throws AWTException {
        String sentence ="";
        Scanner in = new Scanner(System.in);
        while (true){
            System.out.println("请输入你需要输出的词语");
            String line = in.next();
            if (line.equals("退出")) break;
            sentence += line + "/";
        }
        Random r = new Random();
        Robot robot = new Robot();
        robot.delay(3000);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        //根据字符串分割
        String[] authon=sentence.split("[/]");
        for (int j = 0; j < 50; j++) {
            for (int i = 0; i < authon.length; i++) {
                String sentencet=authon[r.nextInt(authon.length)];
                Transferable Ttest=new StringSelection(sentencet);
                clipboard.setContents(Ttest,null);
                robot.keyPress(KeyEvent.VK_CONTROL);// 按下Control键
                robot.keyPress(KeyEvent.VK_V);// 按下V键
                robot.keyRelease(KeyEvent.VK_CONTROL);// 释放Ctrl按键
                robot.delay(250);// 延迟一秒发送
                robot.keyPress(KeyEvent.VK_ENTER);// 回车
            }
        }
    }
}